import { reactive, computed } from 'vue'
export default (props: any, emits: any) => {
    
    const state = reactive({
        dialog: {
            loading: false,
            visible: true,
        }
    })

    const formOptions = computed(() => {
        const {
            data, initData, labelWidth, span, labelAlign,
            customFooter, submitFetch, submitAlign = 'right',
            submitText, view, serialization, log,
            parentData, parentInitData
        } = props.options.config

        return {
            config: {
                data, initData, labelWidth, span, labelAlign,
                customFooter, submitFetch, submitAlign,
                submitText, view, serialization, log,
                parentData, parentInitData,
                parentUIName: 'DialogDrawerForm'
            },
            body: props.options.body
        }
    })

    const closed = (val: any) => {
        emits('closed', val)
    }

    return {
        state,
        formOptions,
        closed
    }
}